package school.emm;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.WindowManager;
import android.widget.ArrayAdapter;
import android.widget.EditText;
import android.widget.Spinner;

public class CreateChatRoomActivity extends Activity {
	Spinner s_;
	EditText topic_;
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		getWindow().setFlags(WindowManager.LayoutParams.FLAG_BLUR_BEHIND, WindowManager.LayoutParams.FLAG_BLUR_BEHIND);
		setContentView(R.layout.createchat);
		topic_ = (EditText) findViewById(R.id.txtValue);
		s_ = (Spinner) findViewById(R.id.spinner);
		ArrayAdapter adapter = ArrayAdapter.createFromResource(this, R.array.categories, android.R.layout.simple_spinner_item);
		adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
		s_.setAdapter(adapter);

	}
	public void createRoom(View v) {
		Intent data = new Intent();

		Bundle bundle = new Bundle();
		bundle.putString("topic", topic_.getText().toString());
		bundle.putInt("category", (int) s_.getSelectedItemId());
		bundle.putInt("X", getIntent().getBundleExtra("bundle").getInt("X"));
		bundle.putInt("Y", getIntent().getBundleExtra("bundle").getInt("Y"));

		System.out.println("topic: " + topic_.getText().toString());
		System.out.println("category: " + s_.getSelectedItem().toString());
		System.out.println("X: " + getIntent().getBundleExtra("bundle").getInt("X") + " Y: " + getIntent().getBundleExtra("bundle").getInt("Y"));

		data.putExtras(bundle);
		setResult(RESULT_OK, data);
		finish();
	}

	public void cancel(View v) {
		setResult(RESULT_CANCELED);
		finish();
	}
}
